<template>
  <div v-show="dialogVisible">
    <div class="mask" @click.self="closeDialog"></div>
    <div class="dialog">
      <div class="dialog-top">错误提示</div>
      <div class="dialog-main">同学，你一共有{{ count }}处错误，请查看解析</div>
      <div class="dialog-bottom" @click="closeDialog">查看解析</div>
    </div>
  </div>
</template>

<script setup lang="ts">
const count = ref(0)
const dialogVisible = ref(false)

const showFn = (num: number) => {
  count.value = num
  dialogVisible.value = true
}

// 关闭弹窗
const closeDialog = () => {
  dialogVisible.value = false
}

defineExpose({
  showFn,
})
</script>

<style lang="scss" scoped>
.mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.65);
  z-index: 999;
}

.dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
  z-index: 1000;
  border-radius: 20px;
  overflow: hidden;

  .dialog-top {
    height: 60px;
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #f2652c;
    font-weight: 600;
    background-color: #fff;
    border-bottom: 2px solid #ccc;
  }

  .dialog-main {
    height: 160px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fff;
    letter-spacing: 2px;
  }

  .dialog-bottom {
    cursor: pointer;
    height: 60px;
    color: #fff;
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    background-image: linear-gradient(to bottom, #96cdec, #2b78e4);
  }
}
</style>
